﻿
using GCC.APIContainer.Utilities;
using GCC.Container.Abstracts;

using Microsoft.AspNetCore.Mvc;

#pragma warning disable CA1822 // Mark members as static
namespace TTGIS.TileServer.API
{
    /// <summary>
    /// 瓦片图服务
    /// </summary>
    [ApiController]
    [Route("TileServer/[controller]")]
    public class TileController : GCCAPIControllerBase
    {
        private static readonly byte[] _empty = Array.Empty<byte>();
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="context"></param>
        public TileController(AbsGCCContext context) : base(context)
        {
        }

        /// <summary>
        /// 根据投影平面笛卡尔坐标获取卫星图瓦片
        /// </summary>
        /// <param name="zoom">缩放等级</param>
        /// <param name="x">x坐标</param>
        /// <param name="y">y坐标</param>
        /// <returns></returns>
        [HttpGet("satellite/{zoom}/{x}/{y}.png")]
        public ActionResult Get([FromRoute] int zoom, [FromRoute] long x, [FromRoute] long y)
        {
            var data = FileCache.Instance?.GetImageBytes(1542757547, x, y, zoom);
            return new FileContentResult(data ?? _empty, "image/png");
        }
        /// <summary>
        /// 根据投影平面笛卡尔坐标获取道路图瓦片
        /// </summary>
        /// <param name="zoom">缩放等级</param>
        /// <param name="x">x坐标</param>
        /// <param name="y">y坐标</param>
        /// <returns></returns>
        [HttpGet("roadInfo/{zoom}/{x}/{y}.png")]
        public ActionResult GetRoadInfo([FromRoute] int zoom, [FromRoute] long x, [FromRoute] long y)
        {
            var data = FileCache.Instance?.GetImageBytes(1447870524, x, y, zoom);
            return new FileContentResult(data ?? _empty, "image/png");
        }

    }
}

#pragma warning restore CA1822 // Mark members as static